﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

using SpectrEngine.Framework.Collision;

namespace SpectrEngine.Framework
{
    public class CollidableGameNode
        : DrawableGameNode, ICollidableItem
    {
        public CollidableGameNode(Game game, Vector2 position, float rotation, Vector2 size)
            : base(game, position, rotation, size)
        {
            bounds = null;
        }

        #region ICollidableItem Members

        private bool collided;
        public bool Collided
        {
            get { return collided; }
            set
            {
                if (collided != value)
                {
                    collided = value;
                    onCollidedChanged();
                }
            }
        }

        protected internal virtual void onCollidedChanged()
        {
            if (CollidedChanged != null)
            {
                CollidedChanged(this, EventArgs.Empty);
            }
        }

        protected BoundingCircle[] hitZones;

        public BoundingCircle[] HitZones
        {
            get { return HitZones; }
        }

        protected BoundingCircle[] attackZones;

        public BoundingCircle[] AttackZones
        {
            get { return attackZones; }
        }

        protected BoundingRect bounds;
        public BoundingRect Bounds
        {
            get { return bounds.Transform(World); }
        }

        public event EventHandler CollidedChanged;

        public virtual void CollideWith(CollidableGameNode other)
        {
        }

        #endregion
    }
}
